<?php

$show_item_num = 12;

//准备装载数据
	require_once("./includes/configure.php");
	require_once("./includes/database.php");
	$db = Database::Connect();
	//$zufang_quyu_array = $db->getConfigurationArray('zufang_quyu');
	$sql = "select A.this_id,A.`value` as quyu,B.this_id as this_id2,B.`value` as quyu2 from configuration A
			left join configuration B
			on A.`this_id` = B.`A`
			WHERE A.`key` ='zufang_quyu'
			and B.`key` ='zufang_shangquan'
			ORDER BY A.sort,B.sort";
	$zufang_quyu_array = $db->GetResultSet($sql);
	
	$xiaoqu_sql = "select * from xiaoqu
					where isSystem=1
					ORDER BY quyu,quyu2";
	$zufang_xiaoqu_array = $db->GetResultSet($xiaoqu_sql);
	
	$hot_xiaoqu_sql = "select A.*,B.`value` from xiaoqu A
					left join configuration B
					on A.quyu2=B.this_id
					where isSystem = 1
					order by liulancishu desc limit $show_item_num";
	$zufang_hot_xiaoqu_array = $db->GetResultSet($hot_xiaoqu_sql);

?>
<div class="hotcomm_boxer" id="hotcomm_boxer">
	<ul class="tab_bar" id="">
		<li class="tab_bar_left" 
			onMouseMove="showdiv('xiaoqu_hot')" id="xiaoqu_hot_li">
			<span class="tab_on">热门小区</span></li>
		
		<?php
			$ii = 0;
			$this_id_temp = 0;
			while ($count_row = mysql_fetch_array($zufang_quyu_array)) {
				if($this_id_temp == $count_row['this_id']){
					continue;
				}else{
					$this_id_temp = $count_row['this_id'];
				}
				$ii++;
				echo '<li rel="'.$count_row['this_id'].'" 
					onMouseMove="showdiv(\'quyu'.$count_row['this_id'].'\')"  id="quyu'.$count_row['this_id'].'_li">
				<a href="xiaoqu.php?quyu='.$count_row['this_id'].'" class="tab" id="tab_'.$ii.'">
				'.$count_row['quyu'].'</a></li>';
			}
		?>
		
		<li class="tab_bar_right"><a
			href="xiaoqu.php" rel="nofollow">更多区域&gt;&gt;</a></li>
	</ul>
	<ul class="hotcomm_list" id="xiaoqu_hot">
		<?php
			while ($hot_xiaoqu_item = mysql_fetch_array($zufang_hot_xiaoqu_array)) {
		?>
			<li>
				<a	href="quyu2=<?=$hot_xiaoqu_item['quyu2']?>"><?=$hot_xiaoqu_item['value']?></a>
				-
				<a	href="xiaoqu_detail.php?id=<?=$hot_xiaoqu_item['this_id']?>" class="apr3"><?=$hot_xiaoqu_item['xiaoquming']?></a>
				<a	href="xiaoqu_detail.php?id=<?=$hot_xiaoqu_item['this_id']?>&section=zu"	class="gray apl3">租</a>
				<a	href="xiaoqu_detail.php?id=<?=$hot_xiaoqu_item['this_id']?>&section=shou"	class="gray">售</a>
			</li>
		<?php
			}
		?>
	</ul>
	
	<?php
		$this_id_temp = 0;
		mysql_data_seek($zufang_quyu_array,0);
		while ($count_row_1 = mysql_fetch_array($zufang_quyu_array)) {
			if($this_id_temp == $count_row_1['this_id']){
				continue;
			}else{
				$this_id_temp = $count_row_1['this_id'];
			}
			//区域1:this_id_temp
	?>
	
		<ul class="hotcomm_list" id="quyu<?=$this_id_temp?>" style="display:none;">
			
			<?php
				mysql_data_seek($zufang_xiaoqu_array,0);
				$this_this_zufang_xiaoqu_array = 0;
				while ($xiaoqu_item = mysql_fetch_array($zufang_xiaoqu_array)) {
					if($xiaoqu_item['quyu']!=$this_id_temp){
						continue;//如果有问题就用continue , 不过不可能有问题;
					}
					if($this_this_zufang_xiaoqu_array==$show_item_num){
						break;
					}
					$this_this_zufang_xiaoqu_array++;
			?>
				<li>
					<a	href="quyu2=<?=$xiaoqu_item['quyu2']?>"><?=$count_row_1['quyu2']?></a>
					-
					<a	href="xiaoqu_detail.php?id=<?=$xiaoqu_item['this_id']?>" class="apr3"><?=$xiaoqu_item['xiaoquming']?></a>
					<a	href="xiaoqu_detail.php?id=<?=$xiaoqu_item['this_id']?>&section=zu"	class="gray apl3">租</a>
					<a	href="xiaoqu_detail.php?id=<?=$xiaoqu_item['this_id']?>&section=shou"	class="gray">售</a>
				</li>
			<?php
				}
			?>
			
		</ul>
	
	<?php
		}
	?>

</div>
<script type="text/javascript">
 
	//在鼠标显示一个层，该层的内空为div2的内容  
	function showdiv(id)
	{
	  closediv("xiaoqu_hot");
	  <?php
		$this_id_temp = 0;
		mysql_data_seek($zufang_quyu_array,0);
		while ($count_row = mysql_fetch_array($zufang_quyu_array)) {
			if($this_id_temp == $count_row['this_id']){
				continue;
			}else{
				$this_id_temp = $count_row['this_id'];
				echo 'closediv("quyu'.$this_id_temp.'");';
			}
		}
	  ?>
	  var div2 = document.getElementById(id);
	  div2.style.display="block";
	  //var div3 = document.getElementById(id+"_li");  
	  //div3.className="tab_bar_left";
	}
	 
	//关闭层div2的显示  
	function closediv(id)
	{
	  var div2 = document.getElementById(id);  
	  div2.style.display="none";
	  
	  //var div3 = document.getElementById(id+"_li");  
	  //div3.className="";
	  
	}  
	
</script> 